package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.TravelPaperQuery;
import cn.wolfcode.trip.base.service.ITravelPaperContentService;
import cn.wolfcode.trip.base.service.ITravelPaperService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("travelPapers")
public class TravelPaperController {
    @Autowired
    private ITravelPaperService travelPaperService;

    @Autowired
    private ITravelPaperContentService travelPaperContentService;

    @GetMapping
    public Object list(TravelPaperQuery qo){
        qo.setOrderBy("t.releaseTime desc");
        PageInfo pageInfo = travelPaperService.selectForList(qo);
        return pageInfo;
    }

    @GetMapping("/{id}")
    public Object getContentBytravelPaperId(@PathVariable Long id){
        return travelPaperContentService.selectByTravelPaperId(id);
    }

}
